package org.ilead.iserve.service.impl;

import java.util.List;
import org.ilead.iserve.dao.IHelpInformationMessageDAO;
import org.ilead.iserve.model.HelpInformationMessage;
import org.ilead.iserve.service.IHelpInformationMessageService;

public class HelpInformationMessageService implements IHelpInformationMessageService {
	private IHelpInformationMessageDAO helpInformationMessageDAO = null;

	public void setHelpInformationMessageDAO(IHelpInformationMessageDAO helpInformationMessageDAO) {
		this.helpInformationMessageDAO = helpInformationMessageDAO;
	}

	@Override
	public Long save(HelpInformationMessage helpInformationMessage) throws Exception {
		return helpInformationMessageDAO.save(helpInformationMessage);
	}

	@Override
	public void update(HelpInformationMessage helpInformationMessage) throws Exception {
		helpInformationMessageDAO.update(helpInformationMessage);

	}

	@Override
	public void delete(Long id) throws Exception {
		helpInformationMessageDAO.delete(findById(id));

	}

	@Override
	public List<HelpInformationMessage> findByTopicId(Long topicId) {
		return helpInformationMessageDAO.findByTopicId(topicId);
	}

	@Override
	public HelpInformationMessage findById(Long id) {
		return helpInformationMessageDAO.findById(id);
	}

	@Override
	public void saveAll(HelpInformationMessage helpInformationMessage)
			throws Exception {
		Long id = save(helpInformationMessage);
		helpInformationMessage = findById(id);
		helpInformationMessage.setPid(new Long(-1));
		helpInformationMessage.setRid(id);
		update(helpInformationMessage);
		
	}

}
